<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:composite="http://java.sun.com/jsf/composite"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:p="http://primefaces.org/ui"
	xmlns:c="http://java.sun.com/jsp/jstl/core"
	xmlns:f="http://java.sun.com/jsf/core">
	

<composite:interface>
	<composite:attribute name="title" />
</composite:interface>

<composite:implementation>
<c:if test="#{userBean.isLoggedIn()}">
	<p:messages id="messages" showDetail="true" autoUpdate="true" closable="true" />
	<h2>User Overview:</h2>
	<h:form id="showUsers">
		<p:dataTable id="cmList" value="#{userBean.users}" var="user">
			<p:column headerText="ID">			
				#{user.id}
			</p:column>
			<p:column headerText="First name">						
				#{user.firstName}			
			</p:column>
			<p:column headerText="Last name">			
				#{user.lastName}
			</p:column>
			<p:column headerText="Add/Remove friend">	
				<p:commandButton id="addFriend" value="Add Friend" actionListener="#{userBean.addFriend(user)}" icon="ui-icon-disk" ajax="false" rendered="#{userBean.isFriendable(user)}"/>		
				<p:commandButton id="removeFriend" value="Remove Friend" actionListener="#{userBean.removeFriend(user)}" icon="ui-icon-disk" ajax="false" rendered="#{userBean.isDeFriendable(user)}"/>
			</p:column>
		</p:dataTable>	
	</h:form>
</c:if>
</composite:implementation>
</html>